/// @author: END
/// @date 2022-01-27

/// 是否需要弹提示
import 'package:aidou/http/code.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:dio/dio.dart';

const NOT_TIP_KEY = 'noTip';

class ErrorInterceptors extends InterceptorsWrapper {
  // final Dio _dio;

  // ErrorInterceptors(this._dio);

  @override
  onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
    final Connectivity _connectivity = Connectivity();
    ConnectivityResult connectivityResult =
        await _connectivity.checkConnectivity();
    if (connectivityResult == ConnectivityResult.none) {
      return handler.resolve(Response(
          requestOptions: options, data: {'code': Code.NETWORK_ERROR}));
    }
    return handler.next(options);
  }
}
